package com.ebt.m.utils.imageloader;

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.ebt.m.AppContext;


/**
 * 图片加载类
 */
public class ImageMgr {
    public static final String PIC_DEFALUT = "defalut";

    private static ImageMgr imageManager;

    public static ImageMgr getInstance() {
        if (imageManager == null) {
            imageManager = new ImageMgr();
        }
        return imageManager;
    }

    /**
     * 构造器
     */
    private ImageMgr() {
    }

    /**
     * 显示图片
     */
    public void displayImage(ImageView imageView, Object value, String displayType) {
        if (imageView instanceof ImageView) {
            if (value instanceof String) {
                String valueStr = (String) value;
                ImageLoaderUtil.getInstance().loadImage(AppContext.getInstance(), new ImageLoader.Builder().url(valueStr).imgView(imageView).build());
            } else if (value instanceof Drawable) {
                ((ImageView) imageView).setImageDrawable((Drawable) value);
            } else if (value instanceof Bitmap) {
                ((ImageView) imageView).setImageBitmap((Bitmap) value);
            } else if (value instanceof Integer) {
                ((ImageView) imageView).setImageResource((Integer) value);
            }
        }
    }


}